[wechall] PHP 0819¶
Source Analysis¶
<?php
// closure, because of namespace!
$challenge = function()
{
$f = Common::getGetString('eval');
$f = str_replace(array('`', '$', '*', '#', ':', '\\', '"', "'", '(', ')', '.', '>'), '', $f);
if((strlen($f) > 13) || (false !== stripos($f, 'return')))
{
die('sorry, not allowed!');
}
try
{
eval("\$spaceone = $f");
}
catch (Exception $e)
{
return false;
}
return ($spaceone === '1337');
};
?>
solve¶
- spaceone이 1337 문자열일 경우 풀리는 문제인데, eval=1337로 입력할 경우 int값으로 입력되어 에러가 출력됩니다.
- heredoc 구문을 이용하여 해결할 수 있습니다. "<<<"
http://zetawiki.com/wiki/PHP_%ED%9E%88%EC%96%B4%EB%8B%A5_heredoc
<<<a
1337
a;